Skip to content

feat(openai): Make include_prompts override data collection when set - #6981

Open
ericapisani wants to merge 1 commit into
py-2588-openai-embeddings-input-datafrom
py-2588-openai-modify-include-prompt-override-defaults
Open

feat(openai): Make include_prompts override data collection when set#6981
ericapisani wants to merge 1 commit into
py-2588-openai-embeddings-input-datafrom
py-2588-openai-modify-include-prompt-override-defaults

Conversation

@ericapisani

Copy link
Copy Markdown
Member

Change the default of OpenAIIntegration's include_prompts from True to None (unset). When unset, prompt collection follows the global data_collection.gen_ai.inputs setting; when explicitly set, it takes precedence over the global setting in both directions.

The unset default is resolved lazily at call time rather than in init, so integrations constructed before sentry_sdk.init() still see the active client's options. Pre-data-collection behavior (defaults to True, subject to send_default_pii) is preserved.

Refs PY-2588

Change the default of OpenAIIntegration's include_prompts from True to
None (unset). When unset, prompt collection follows the global
data_collection.gen_ai.inputs setting; when explicitly set, it takes
precedence over the global setting in both directions.

The unset default is resolved lazily at call time rather than in
__init__, so integrations constructed before sentry_sdk.init() still
see the active client's options. Pre-data-collection behavior
(defaults to True, subject to send_default_pii) is preserved.

Refs PY-2588
@ericapisani
ericapisani requested a review from a team as a code owner July 31, 2026 19:27
@linear-code

linear-code Bot commented Jul 31, 2026

Copy link
Copy Markdown

PY-2588

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a033d03. Configure here.

# to send_default_pii). Resolve the unset default here, at call time,
# rather than in __init__ so that integrations constructed before
# sentry_sdk.init() still see the active client's options.
integration.include_prompts = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unset prompts skip response capture

Medium Severity

When data collection is enabled, _resolve_include_prompts leaves include_prompts as None. Input paths handle that, but response-body gates still use truthiness checks like should_send_default_pii() and integration.include_prompts, so None suppresses gen_ai.response.text even when send_default_pii is on. The default path therefore silently drops AI outputs.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a033d03. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

97278 passed | ⏭️ 6487 skipped | Total: 103765 | Pass Rate: 93.75% | Execution Time: 345m 37s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +2440
Passed Tests 📈 +2297
Failed Tests 📉 -1
Skipped Tests 📈 +144

➖ Removed Tests (1)

View removed tests
  • test_continuous_profiler_auto_start_and_stop_sampled_span_streaming[non-experiment-thread]
    • File: tests.profiler.test_continuous_profiler

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2511 uncovered lines.
✅ Project coverage is 89.9%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.88%    89.90%    +0.02%
==========================================
  Files          193       193         —
  Lines        24832     24853       +21
  Branches      8912      8932       +20
==========================================
+ Hits         22319     22342       +23
- Misses        2513      2511        -2
- Partials      1416      1414        -2

Generated by Codecov Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant